﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/ContentFrame.master" AutoEventWireup="true" CodeBehind="Organizations.aspx.cs" Inherits="ETD.WebManagement.Admin.OrganizationManage.Organizations" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style>
        .rtlDataDiv {
            height: unset !important;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManagerDefault">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="searchPanel" />
                    <telerik:AjaxUpdatedControl ControlID="rtlOrganizations" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="rtlOrganizations">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rtlOrganizations" LoadingPanelID="loadingPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>

        </AjaxSettings>
    </telerik:RadAjaxManager>

    <asp:Panel ID="SearchPanel" runat="server">
        <telerik:RadDockLayout ID="SearchRadDockLayout" runat="server">
            <telerik:RadDockZone ID="SearchRadDockZone" runat="server" Orientation="Vertical" BorderWidth="0"
                Resizable="true">
                <telerik:RadDock ID="SearchRadDock" runat="server" Title="搜索：" EnableDrag="false"
                    DockHandle="TitleBar" DockMode="Docked" EnableAnimation="true" EnableRoundedCorners="false">
                    <ContentTemplate>
                        <div class="searchPanel">
                            <div>
                                <label>机构名称：</label>
                                <telerik:RadTextBox ID="txtOrganizationName" Width="120px" runat="server"></telerik:RadTextBox>
                            </div>
                            <div>
                                <label>备注：</label>
                                <telerik:RadTextBox ID="txtRemark" Width="120px" runat="server"></telerik:RadTextBox>
                            </div>
                            <div>
                                <telerik:RadButton runat="server" ID="btnSearch" Text="搜索"></telerik:RadButton>
                                &nbsp; &nbsp;
                                 <telerik:RadButton runat="server" ID="btnAdd" AutoPostBack="false" OnClientClicked="rtlOrganizationsOnInsertCommand"
                                     Text="添加">
                                 </telerik:RadButton>

                            </div>
                        </div>

                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
        <div style="height: 10px;"></div>
    </asp:Panel>


    <telerik:RadTreeList ID="rtlOrganizations" runat="server" OnNeedDataSource="rtlOrganizations_NeedDataSource" ClientSettings-Selecting-AllowItemSelection="true"
        ParentDataKeyNames="ParentOrganizationID" DataKeyNames="OrganizationID" AllowPaging="true" PageSize="1000" GridLines="Both"
        AutoGenerateColumns="false" AllowSorting="true" OnItemUpdated="rtlOrganizations_ItemUpdated" AllowMultiItemEdit="true" OnItemCommand="rtlOrganizations_ItemCommand"
        OnUpdateCommand="rtlOrganizations_UpdateCommand" OnInsertCommand="rtlOrganizations_InsertCommand"
        EditMode="InPlace" ExpandCollapseMode="Combined" ClientSettings-Scrolling-AllowScroll="true">

        <EditFormSettings EditColumn-ButtonType="ImageButton">
            <FormMainTableStyle Width="100%" />
        </EditFormSettings>

        <Columns>
            <telerik:TreeListBoundColumn DataField="Name" UniqueName="Name"
                HeaderText="机构名称">
                <HeaderStyle Width="200px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="OrganizationTypeName" UniqueName="OrganizationTypeName"
                HeaderText="类型">
                <HeaderStyle Width="60px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="OrganizationStatusName" UniqueName="OrganizationStatusName"
                HeaderText="状态">
                <HeaderStyle Width="80px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="ProvinceRegionName" UniqueName="ProvinceRegionName"
                HeaderText="省份">
                <HeaderStyle Width="60px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="CityRegionName" UniqueName="CityRegionName"
                HeaderText="市">
                <HeaderStyle Width="60px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="CityRegionName" UniqueName="CityRegionName"
                HeaderText="区">
                <HeaderStyle Width="60px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="Address" UniqueName="Address"
                HeaderText="地址">
                <HeaderStyle Width="100px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="PhoneNumber" UniqueName="PhoneNumber"
                HeaderText="电话">
                <HeaderStyle Width="100px" />
            </telerik:TreeListBoundColumn>
             <telerik:TreeListBoundColumn DataField="TotalIncome" UniqueName="TotalIncome"
                HeaderText="总收入">
                <HeaderStyle Width="100px" />
            </telerik:TreeListBoundColumn>
             <telerik:TreeListBoundColumn DataField="Balance" UniqueName="Balance"
                HeaderText="余额">
                <HeaderStyle Width="100px" />
            </telerik:TreeListBoundColumn>
            <%--            <telerik:TreeListTemplateColumn DataField="OrganizationID" UniqueName="OrganizationID"
                HeaderText="主ID">
                <ItemStyle Width="40px" />
                <HeaderStyle Width="40px" />
                <ItemTemplate>
                    <%# Eval("OrganizationID").ToString()%>
                </ItemTemplate>
                <EditItemTemplate>
                    <%# Eval("OrganizationID").ToString()%>
                </EditItemTemplate>

            </telerik:TreeListTemplateColumn>
            <telerik:TreeListTemplateColumn DataField="ParentOrganizationID" UniqueName="ParentOrganizationID"
                HeaderText="父ID">
                <ItemStyle Width="40px" />
                <HeaderStyle Width="40px" />
                <ItemTemplate>
                    <%# Eval("ParentOrganizationID")!=null?Eval("ParentOrganizationID").ToString():"--"%>
                </ItemTemplate>
                <EditItemTemplate>
                    <%# Eval("ParentOrganizationID")!=null?Eval("ParentOrganizationID").ToString():"--"%>
                </EditItemTemplate>

            </telerik:TreeListTemplateColumn>--%>

            <%-- <telerik:TreeListEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderText="操作">
                <ItemStyle Width="90px" />
                <HeaderStyle Width="90px" />
            </telerik:TreeListEditCommandColumn>--%>

            <telerik:TreeListBoundColumn DataField="" UniqueName="Temp" HeaderText="" />
            <telerik:TreeListTemplateColumn HeaderText="操作" UniqueName="txtColDescription"
                HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                <ItemStyle Width="200px" />
                <HeaderStyle Width="200px" />
                <ItemTemplate>
                    <a class="gridActionButton" onclick="rtlOrganizationsOnNewSettlementCommand('<%#Eval("OrganizationID").ToString() %>');">提现</a>
                    <a class="gridActionButton" onclick="rtlOrganizationsOnViewSectionOfficesCommand('<%#Eval("OrganizationID").ToString() %>');">增加/减扣</a>
                    <a class="gridActionButton" onclick="rtlOrganizationsOnViewSectionOfficesCommand('<%#Eval("OrganizationID").ToString() %>');">科室</a>
                      <a class="gridActionButton" onclick="rtlOrganizationsOnViewProfitRuleTiersCommand('<%#Eval("OrganizationID").ToString() %>');">分成</a>
                    <a class="gridActionButton" onclick="rtlOrganizationsOnEditCommand('<%#Eval("OrganizationID").ToString() %>');">编辑</a>
                    <a class="gridActionButton" onclick="rtlOrganizationsOnDeleteCommand(this,'<%#Eval("OrganizationID").ToString() %>');">删除</a>
                    <asp:Button ID="lbtnDeleteHiden" CssClass="hidden" runat="server" CommandName="Delete" />
                </ItemTemplate>
            </telerik:TreeListTemplateColumn>
        </Columns>

    </telerik:RadTreeList>

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var OrganizationEditPageUrl = '<%=ResolveClientUrl("/Admin/OrganizationManage/OrganizationEdit.aspx?OrganizationID=") %>';
            var OrganizationSettlementEditPageUrl = '<%=ResolveClientUrl("/Admin/OrganizationManage/OrganizationSettlementEdit.aspx?OrganizationID=") %>';
            
            var SectionOfficesPageUrl = '<%=ResolveClientUrl("/Admin/OrganizationManage/SectionOffices.aspx?OrganizationID=") %>';
            var OrganizationProfitRuleTiersPageUrl = '<%=ResolveClientUrl("/Admin/OrganizationManage/ProfitRuleTiers.aspx?OrganizationID=") %>';
            var rtlOrganizations = null;
            $(document).ready(function () {
                rtlOrganizations = $find('<%=rtlOrganizations.ClientID %>');
            });



            function rtlOrganizationsOnCommand(sender, eventArgs) {
                //retrieve the current commandName and commandArgument
                var commandName = eventArgs.get_commandName();
                if (commandName == "InitInsert") {
                    rtlOrganizationsOnInsertCommand(eventArgs);
                }
                else if (commandName == "Edit") {

                }

                //eventArgs.set_cancel(true); //cancel the command
            }
            function rtlOrganizationsOnInsertCommand(eventArgs) {
                var addUrl = OrganizationEditPageUrl + "-1";
                DefaultWindow.openWindow('添加机构', addUrl, 900, 500);
                DefaultWindow.maximize();
                //eventArgs.set_cancel(true);
            }
            function rtlOrganizationsOnEditCommand(OrganizationID) {
                var editUrl = OrganizationEditPageUrl + OrganizationID;
                DefaultWindow.openWindow('编辑机构', editUrl, 900, 500);
                DefaultWindow.maximize();
                //eventArgs.set_cancel(true);
            }
            function rtlOrganizationsOnNewSettlementCommand(OrganizationID) {
                var editUrl = OrganizationSettlementEditPageUrl + OrganizationID;
                DefaultWindow.openWindow('提现', editUrl, 900, 500);
                //DefaultWindow.maximize();
                //eventArgs.set_cancel(true);
            }
            function rtlOrganizationsOnViewSectionOfficesCommand(OrganizationID) {
                var editUrl = SectionOfficesPageUrl + OrganizationID;
                window.location.href = editUrl;
            }
            function rtlOrganizationsOnViewProfitRuleTiersCommand(OrganizationID) {
                var editUrl = OrganizationProfitRuleTiersPageUrl + OrganizationID;
                window.location.href = editUrl;
            }
            
            function rtlOrganizationsOnDeleteCommand(self, OrganizationID) {
                onDeleteRadconfirm('确定要删除吗？', function (arg) {
                    if (arg) {
                        $(self).next().click();
                    }
                });
            }

            function refreshPageWithState() {
                window.location.reload();
            }

        </script>

    </telerik:RadCodeBlock>
</asp:Content>
